package com.company.common.api.wrap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.company.cloud.common.redis.service.RedisUtils;
import com.company.common.api.wrap.config.ApiWrapProperties;
import com.company.common.api.wrap.handler.WrapHandler;
import com.company.common.api.wrap.handler.WrapHandlerServer;
import com.company.common.api.wrap.store.RedisWrapStore;
import com.company.common.api.wrap.store.WrapStore;

@Configuration
//@ConditionalOnBean(value = {ApiWrapConfiguration.Marker.class})
//@EnableConfigurationProperties({ApiWrapProperties.class})
//@Import({AopAutoConfiguration.class, RedisAutoConfiguration.class})
public class ApiWrapAutoConfiguration {

	@Bean
	public ApiWrapAspect apiWrapAspect() {
		return new ApiWrapAspect();
	}

	@Bean
	@ConditionalOnMissingBean
	public WrapStore wrapStore(@Autowired RedisUtils redisUtils) {
		return new RedisWrapStore(redisUtils);
	}

	
	
	@Bean
	@ConditionalOnMissingBean
	public WrapHandler defaultWrapHandler(@Autowired ApiWrapProperties apiWrapProperties, @Autowired WrapStore wrapStore) {
		return new WrapHandlerServer(apiWrapProperties, wrapStore);
	}
	

}
